/**
 * xmlstorer.h is part of Gedule.
 *
 * Gedule is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gedule is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Gedule.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef XMLSTORER_H
#define XMLSTORER_H

#include "storer.h"
#include <QXmlStreamWriter>

class XmlStorer : public Storer
{
public:
    XmlStorer( const std::string & a_file );

    virtual ~XmlStorer();

    virtual bool Store( Model & a_model );

    virtual void Visit( Model * a_model );
    virtual void Visit( Task * a_task );
    virtual void Visit( Resource * a_resource );
    virtual void Visit( TimeWindow * a_constraint );
    virtual void Visit( Lenght * a_constraint );
    virtual void Visit( NeededResources * a_constraint );
    virtual void Visit( Capacity * a_constraint );
    virtual void Visit( Unavailabilities * a_constraint );
    virtual void Visit( AllowIdles * a_constraint );
    virtual void Visit( MaxTime * a_constraint );
    virtual void Visit( Precedence * a_constraint );

private:

    // Fields
    // ------

    QXmlStreamWriter    m_writer;
    bool                m_mustEndModelElement;
    bool                m_mustEndTaskElement;
    bool                m_mustEndResourceElement;
    std::string         m_file;

    // Methods
    // -------

    void WriteEndElementIfNeeded();

    // Protect default constructor.
    XmlStorer();

    // Protect default copy contructor.
    XmlStorer( const XmlStorer & a_other );

    // Protect default operator =.
    XmlStorer & operator = ( const XmlStorer & a_other );

};

#endif // XMLSTORER_H
